home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / enscript.4 / enscript / enscript-1.4.0 / afmlib / afmint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-24  |  5.3 KB  |  291 lines

  1. /* 
  2.  * Internal header for the AFM library.
  3.  * Copyright (c) 1995 Markku Rossi.
  4.  *
  5.  * Author: Markku Rossi <mtr@iki.fi>
  6.  */
  7.  
  8. /*
  9.  * This file is part of the AFM library.
  10.  * 
  11.  * This library is free software; you can redistribute it and/or
  12.  * modify it under the terms of the GNU Library General Public
  13.  * License as published by the Free Software Foundation; either
  14.  * version 2 of the License, or (at your option) any later version.
  15.  *
  16.  * This library is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19.  * Library General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU Library General Public
  22.  * License along with this library; if not, write to the Free
  23.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  */
  25.  
  26. #ifndef AFMINT_H
  27. #define AFMINT_H
  28.  
  29. /* 
  30.  * Config stuffs.
  31.  */
  32.  
  33. #ifdef HAVE_CONFIG_H
  34. #include <config.h>
  35. #endif
  36.  
  37. #include <stdio.h>
  38.  
  39. #ifndef __P
  40. #if PROTOTYPES
  41. #define __P(protos) protos
  42. #else /* no PROTOTYPES */
  43. #define __P(protos) ()
  44. #endif /* no PROTOTYPES */
  45. #endif
  46.  
  47. #if STDC_HEADERS
  48.  
  49. #include <stdlib.h>
  50. #include <string.h>
  51. #include <stdarg.h>
  52.  
  53. #else /* no STDC_HEADERS */
  54.  
  55. #if HAVE_STDLIB_H
  56. #include <stdlib.h>
  57. #endif
  58.  
  59. #if HAVE_STRING_H
  60. #include <string.h>
  61. #endif
  62.  
  63. #ifndef HAVE_STRCHR
  64. #define strchr index
  65. #define strrchr rindex
  66. #endif
  67. char *strchr ();
  68. char *strrchr ();
  69.  
  70. #ifndef HAVE_MEMCPY
  71. #define memcpy(d, s, n) bcopy((s), (d), (n))
  72. #define memmove(d, s, n) bcopy((s), (d), (n))
  73. #endif
  74.  
  75. #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
  76. #include <stdarg.h>
  77. #else
  78. #include <varargs.h>
  79. #endif
  80.  
  81. #ifndef HAVE_STRERROR
  82. extern char *strerror __P ((int));
  83. #endif
  84.  
  85. #endif /* no STDC_HEADERS */
  86.  
  87. #if HAVE_UNISTD_H
  88. #include <unistd.h>
  89. #endif
  90.  
  91. #include <setjmp.h>
  92. #include <assert.h>
  93. #include <errno.h>
  94.  
  95. #include <sys/types.h>
  96. #include <sys/stat.h>
  97.  
  98. #include "afm.h"
  99. #include "strhash.h"
  100.  
  101.  
  102. /*
  103.  * Types and definitions.
  104.  */
  105.  
  106. /* Error codes. */
  107. #define AFM_ERROR            1
  108. #define AFM_ERROR_MEMORY        2
  109. #define AFM_ERROR_ARGUMENT        3
  110. #define AFM_ERROR_UNKNOWN_FONT        4
  111. #define AFM_ERROR_SYNTAX        5
  112. #define AFM_ERROR_UNSUPPORTED_FORMAT    6
  113. #define AFM_ERROR_FILE_IO        7
  114. #define AFM_ERROR_NOT_AFM_FILE        8
  115. #define NUM_ERRORS            9
  116.  
  117. /* Pack error and global errno. */
  118. #define SYSERROR(code) (errno << 16 | (code))
  119.  
  120.  
  121. /* Keys. */
  122.  
  123. typedef enum
  124. {
  125.   kComment,
  126.  
  127.   /* File structure. */
  128.   kStartFontMetrics,
  129.   kEndFontMetrics,
  130.   kStartCompFontMetrics,
  131.   kEndCompFontMetrics,
  132.   kStartDescendent,
  133.   kEndDescendent,
  134.   kStartMasterFontMetrics,
  135.   kEndMasterFontMetrics,
  136.  
  137.   /* Control information. */
  138.   kMetricsSets,
  139.   kDescendents,
  140.   kMasters,
  141.   kAxes,
  142.  
  143.   /* Global font information. */
  144.   kFontName,
  145.   kFullName,
  146.   kFamilyName,
  147.   kWeight,
  148.   kFontBBox,
  149.   kVersion,
  150.   kNotice,
  151.   kEncodingScheme,
  152.   kMappingScheme,
  153.   kEscChar,
  154.   kCharacterSet,
  155.   kCharacters,
  156.   kIsBaseFont,
  157.   kVVector,
  158.   kIsFixedV,
  159.   kCapHeight,
  160.   kXHeight,
  161.   kAscender,
  162.   kDescender,
  163.   kWeightVector,
  164.   kBlendDesignPositions,
  165.   kBlendDesignMap,
  166.   kBlendAxisTypes,
  167.  
  168.   /* Writing direction information. */
  169.   kStartDirection,
  170.   kEndDirection,
  171.   kUnderlinePosition,
  172.   kUnderlineThickness,
  173.   kItalicAngle,
  174.   kCharWidth,
  175.   kIsFixedPitch,
  176.  
  177.   /* Individual character metrics. */
  178.   kStartCharMetrics,
  179.   kEndCharMetrics,
  180.   kC,
  181.   kCH,
  182.   kWX,
  183.   kW0X,
  184.   kW1X,
  185.   kWY,
  186.   kW0Y,
  187.   kW1Y,
  188.   kW,
  189.   kW0,
  190.   kW1,
  191.   kVV,
  192.   kN,
  193.   kB,
  194.   kL,
  195.  
  196.   /* Kerning data. */
  197.   kStartKernData,
  198.   kEndKernData,
  199.   kStartTrackKern,
  200.   kEndTrackKern,
  201.   kTrackKern,
  202.   kStartKernPairs,
  203.   kEndKernPairs,
  204.   kKP,
  205.   kKPH,
  206.   kKPX,
  207.   kKPY,
  208.   
  209.   /* Composite character data. */
  210.   kStartComposites,
  211.   kEndComposites,
  212.   kCC,
  213.   kPCC,
  214.  
  215.   /* Axis information. */
  216.   kStartAxis,
  217.   kEndAxis,
  218.   kAxisType,
  219.   kAxisLabel,
  220.  
  221.   /* Master Design Information */
  222.   kStartMaster,
  223.   kEndMaster
  224.   
  225. } AFMKey;
  226.  
  227.  
  228. struct afm_handle_st
  229. {
  230.   unsigned int verbose;        /* verbose level */
  231.   StringHashPtr font_map;    /* fontname -> AFM filename mapping */
  232.  
  233.   /* Parse support. */
  234.   jmp_buf jmpbuf;
  235.   AFMError parse_error;        /* Error that caused longjmp(). */
  236. };
  237.  
  238.  
  239. /* Store library's private font data to this structure. */
  240. struct afm_font_private_data_st
  241. {
  242.   /* Character that is used for undefined codes (' '). */
  243.   AFMIndividualCharacterMetrics *undef;
  244.  
  245.   StringHashPtr fontnames;    /* fontname -> character info mapping */
  246.   StringHashPtr compositenames;    /* composite -> AFMComposite mapping */
  247. };
  248.  
  249.  
  250. /*
  251.  * Encoding tables.
  252.  */
  253.  
  254. struct encoding_table_st
  255. {
  256.   int code;
  257.   char *character;
  258. };
  259.  
  260. typedef struct encoding_table_st AFMEncodingTable;
  261.  
  262. extern AFMEncodingTable afm_latin1_encoding[];
  263. extern AFMEncodingTable afm_latin2_encoding[];
  264. extern AFMEncodingTable afm_latin3_encoding[];
  265. extern AFMEncodingTable afm_ibmpc_encoding[];
  266. extern AFMEncodingTable afm_mac_encoding[];
  267. extern AFMEncodingTable afm_vms_encoding[];
  268. extern AFMEncodingTable afm_hp8_encoding[];
  269.  
  270.  
  271. /*
  272.  * Global help functions.
  273.  */
  274.  
  275. /* Print message if <level> is larger than library's verbose level. */
  276. void afm_message __P ((AFMHandle handle, int level, char *fmt, ...));
  277.  
  278. /* Print error message to stderr. */
  279. void afm_error __P ((AFMHandle handle, char *fmt, ...));
  280.  
  281.  
  282. /*
  283.  * AFM file parsing
  284.  */
  285.  
  286. /* Parse AFM file <filename> and fill up font <font>. */
  287. void afm_parse_file __P ((AFMHandle handle, const char *filename,
  288.               AFMFont font));
  289.  
  290. #endif /* not AFMINT_H */
  291.